package org.example.pro2_self_iocContainer;

import org.example.pro2_self_iocContainer.org.annotation.YcBean;
import org.example.pro2_self_iocContainer.org.annotation.YcComponentScan;
import org.example.pro2_self_iocContainer.org.annotation.YcConfiguration;
import org.example.pro2_self_iocContainer.org.context.YcAnnotationConfigApplicationContext;
import org.example.pro2_self_iocContainer.org.context.YcApplicationContext;
import org.example.pro2_self_iocContainer.yc.UserBiz;

@YcConfiguration

//@YcComponentScan
@YcComponentScan(value={"com.zy.project2.yc"})
//@YcComponentScan(basePackages={"com.yc","org.springframework"})

public class AppConfig {

    @YcBean(value="a")
    public Apple apple(){
        return new Apple();
    }

    @YcBean
    public Apple snakeapple(){
        return new Apple();
    }


    public static void main(String[] args) {
        YcApplicationContext ac=new YcAnnotationConfigApplicationContext(AppConfig.class);
        Apple a= (Apple) ac.getBean("a");
        Apple snakeapple= (Apple) ac.getBean("snakeapple");
        System.out.println(   a+"\t"+snakeapple);

        UserBiz ub= (UserBiz) ac.getBean("userBiz");
        ub.show();

        UserBiz ub2= (UserBiz) ac.getBean("userBiz");
        System.out.println(  ub   +"\t"+ub2);
    }
}
